//
//  SpotCreateViewCell.m
//  DigiOps
//
//  Created by app on 2018/7/26.
//  Copyright © 2018年 俞渊华. All rights reserved.
//

#import "SpotCreateViewCell.h"
#import "SpotModel.h"
@implementation SpotCreateViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.spotView.layer.borderColor=[UIColor lightGrayColor].CGColor;
    self.spotView.layer.borderWidth=0.3;
    [self.spotView setBackgroundColor:XMColor(241, 245, 247)];
    _btn1 = [[UIButton alloc] init];
    _btn1.tag = 1;
    [_btn1 setTitle:@"" forState:UIControlStateNormal];
    [_btn1 setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    _btn1.titleLabel.font = [UIFont xm_medium:12];
    [_btn1 setImage:[UIImage imageNamed:@"Down Arrow"] forState:UIControlStateNormal];
    _btn1.imageEdgeInsets = UIEdgeInsetsMake(0, 50, 0, -40);
    _btn1.contentEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);
    [_btn1 setBackgroundColor:XMColor(241, 245, 247)];
    [self.spotView addSubview:_btn1];
    [_btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.spotView.mas_right).offset(-20);
        make.top.equalTo(self.spotView.mas_top);
        make.bottom.equalTo(self.spotView.mas_bottom);
        make.width.equalTo(@(SCREEN_WIDTH/2-120));
    }];
    [_btn1 addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureRecognizer)];
    [self addGestureRecognizer:tapGesture];
    
    [self.spotContent mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.spotView);
        make.centerY.mas_equalTo(self.spotView);

    }];
}
-(void)btnClick:(UIButton*)sender
{
    if (self.block) {
        sender.tag=self.model.ID;
        self.block(sender);
    }

}
-(void)tapGestureRecognizer
{
    int ab= self.model.ID;
    if (self.block) {
        UIButton* a=[[UIButton alloc] init];
        a.tag=ab;
        self.block(a);
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}
+ (SpotCreateViewCell *)cellWithTableView:(UITableView *)tableView {
    static NSString *ID = @"SpotCreateViewCellID";
    
    SpotCreateViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[NSBundle mainBundle] loadNibNamed:@"SpotCreateViewCell" owner:nil options:nil].lastObject;
        cell.backgroundColor=[UIColor whiteColor];
        
    }
    return cell;
}

@end
